package com.runchamp;

/* An object to hold a users live race stats */
public class CurrentStats implements Comparable<CurrentStats> {
    long Key;
    long Race;
    long Racer;
    double Speed;
    double ActualDistance;
    int FinalPosition;
    public CurrentStats(long key, long race, long racer, float speed, float actualDistance) {
        Key = key;
        Race = race;
        Racer = racer;
        Speed = speed;
        ActualDistance = actualDistance;
        //FinalPosition = FinalPosition;

    }

    public CurrentStats() {

    }

    @Override
    public int compareTo(CurrentStats another) {
        if (this.FinalPosition != -1 || another.FinalPosition != -1) { //if anyone finished
            if (this.FinalPosition != -1 && another.FinalPosition != -1) { //if both finished
                if (this.FinalPosition < another.FinalPosition) //this is better
                    return -1;
                else
                    return 1;
            }
            if (this.FinalPosition != -1) { //only one finished
                return -1;
            } else {
                return 1;
            }
        }

        if (this.ActualDistance > another.ActualDistance)
            return -1;
        if (this.ActualDistance < another.ActualDistance)
            return 1;
        else
            return 0;

    }


}
